<?php
class ContentsM extends CI_Model {
	

	
	var $table = 'contents';
	
	function __construct() {
		// call the Model constructor
		parent::__construct ();
//		$this->output->enable_profiler(TRUE);
	}
	
	
	
	
	function count_all() {
		
		$this->db->select ( "id" );
		$query = $this->db->get ( $this->table );
		
		return $query->num_rows ();
	
	}
	
	function getAll() {
	    
		$this->load->database ();
		$query = $this->db->get ( $this->table );
		if ($query->num_rows () > 0) {
			// return result set as an associative array
			return $query->result_array ();
		}
	}
	
	function getContentsWhere($field=null, $param=null) {
	    if (!is_null($field))
		    $this->db->where ( $field, $param );
		$query = $this->db->get ( $this->table );
		// return result set as an associative array
		return $query->result_array ();
	}

	// get total number of users
	function getNumUsers() {
		
		//		$this->load->database();
		return $this->db->count_all ( $this->table );
	
		//		 return 10;
	}
	
	
	
	
}
?>